#include "stdafx.h"
#include "RenderSettingsGui.h"

#include "RenderingSettings.h"
#include "Window.h"
#include "OnOffButton.h"

using namespace medit;

RenderSettingsGui::RenderSettingsGui(mgfx::RenderingSettings * settings)
{
	assert(settings != NULL);
	mSettings = settings;

	createWindow();
}

void RenderSettingsGui::createWindow()
{
	GuiWindow = new mgui::Window(mgui::Rect(20, 50, 200, 500), "Render settings");

	mgui::OnOffButton * button;

	//button = new mgui::OnOffButton(mgui::Rect(10, 30, 160, 20), "Show G-buffer");
	//button->addListener(mgui::OnOffButton::EVENT_STATE_CHANGED, std::bind(&RenderSettingsGui::buttonShowGBuffer, this, std::placeholders::_1));
	//GuiWindow->addChild(button);

	//button = new mgui::OnOffButton(mgui::Rect(10, 60, 160, 20), "Show bounding geo");
	//button->addListener(mgui::OnOffButton::EVENT_STATE_CHANGED, std::bind(&RenderSettingsGui::buttonShowBoundingGeo, this, std::placeholders::_1));
	//GuiWindow->addChild(button);

	//button = new mgui::OnOffButton(mgui::Rect(10, 90, 160, 20), "Render SSAO");
	//button->addListener(mgui::OnOffButton::EVENT_STATE_CHANGED, std::bind(&RenderSettingsGui::buttonRenderSSAO, this, std::placeholders::_1));
	//GuiWindow->addChild(button);

	button = new mgui::OnOffButton(mgui::Rect(10, 30, 160, 20), "Show G-buffer");
	button->addListener(mgui::OnOffButton::EVENT_STATE_CHANGED,
		std::bind(&RenderSettingsGui::buttonFlipSetting, this, &mSettings->ShowGBuffer, std::placeholders::_1));
	GuiWindow->addChild(*button);

	button = new mgui::OnOffButton(mgui::Rect(10, 60, 160, 20), "Show bounding geo");
	button->addListener(mgui::OnOffButton::EVENT_STATE_CHANGED,
		std::bind(&RenderSettingsGui::buttonFlipSetting, this, &mSettings->ShowBoundingSpheres, std::placeholders::_1));
	GuiWindow->addChild(*button);

	button = new mgui::OnOffButton(mgui::Rect(10, 90, 160, 20), "SSAO");
	button->addListener(mgui::OnOffButton::EVENT_STATE_CHANGED,
		std::bind(&RenderSettingsGui::buttonFlipSetting, this, &mSettings->RenderSSAO, std::placeholders::_1));
	GuiWindow->addChild(*button);
}

void RenderSettingsGui::buttonFlipSetting( bool * value, const mgui::EventArgs & args )
{
	*value = ((const mgui::OnOffEventArgs*)(&args))->On;
}
